import {getApplyProject,getProjectBase,getTicketList} from '@/apilist/Finance'

const state = {
    applyList: [],
    baseInfo: {
      company: '',
      start: '',
      stop: '',
      leader: '',
      leader_mobile: '',
      customer: '',
      customer_mobile: '',
      seller: '',
      seller_mobile: '',
      currency: '',
      offer: '',
      cost: '',
      offer_ys: '',
      cost_ys: '',
      offer_js: '',
      cost_js: '',
      city: '',
      limit: '',
    },
    xmid: '',
  ticketList: [],
  ticketType: [],
  ticketCategory: [],
}

const mutations = {
  //获取可申请的项目
    setApplyListMutations(state,data){
      state.applyList = data
    },
  setBaseInfoMutations(state,data){

    state.baseInfo.limit =''
    state.baseInfo.company = data.company
    state.baseInfo.dept = data.dept
    state.baseInfo.start = data.start
    state.baseInfo.stop = data.stop
    state.baseInfo.leader = data.leader
    state.baseInfo.leader_mobile = data.leader_mobile
    state.baseInfo.customer = data.customer
    state.baseInfo.customer_mobile = data.customer_mobile
    state.baseInfo.seller = data.seller
    state.baseInfo.seller_mobile = data.seller_mobile
    state.baseInfo.currency = data.currency
    state.baseInfo.offer = data.offer
    state.baseInfo.cost = data.cost
    state.baseInfo.offer_ys = data.offer_ys
    state.baseInfo.cost_ys = data.cost_ys
    state.baseInfo.offer_js = data.offer_js
    state.baseInfo.cost_js = data.cost_js
    state.baseInfo.city = data.city
    state.baseInfo.limit = data.limit
  },
  setTicketListMutations(state,data){
      state.ticketList = data.list
      state.ticketType = data.type
      state.ticketCategory = data.category
  },
}

const actions = {
  //获取可申请的项目
  async getApplyListActions(ctx,data){
     let res = await getApplyProject(data)
     ctx.commit('setApplyListMutations',res.data)
  },

   async getBaseInfoActions(ctx,data){
    let res =  await getProjectBase(data)
    ctx.commit('setBaseInfoMutations',res.data)
  },

 async getTicketListActions(ctx,data){
    let res = await getTicketList(data)
   ctx.commit('setTicketListMutations',res.data)
 }

}


export default {
  namespaced: true,
  state,
  mutations,
  actions
}
